END Statement ---------------------------------------------------------------------------- Action Stops a BASIC program, procedure, or block. Syntax 1 END -{ DEF | FUNCTION | IF | SELECT | SUB | TYPE}- Syntax 2 END - n%- Remarks There are a number of ways to use the END statement, as described in the following list. ----------------------------------------------------------------------------- Statement Description ---------------------------------------------------------------------------- END DEF Ends a multiline DEF FN function definition. You must use END DEF with a multiline DEF FN. END FUNCTION Ends a FUNCTION procedure definition. You must use END FUNCTION with FUNCTION. END IF Ends a block IF... THEN... ELSE statement. You must use END IF with block IF... THEN... ELSE. END SELECT Ends a SELECT CASE block. You Statement Description ---------------------------------------------------------------------------- END SELECT Ends a SELECT CASE block. You must use END SELECT with a SELECT CASE statement. END SUB Ends a BASIC SUB procedure. You must use END SUB with SUB. END TYPE Ends a user-defined type definition ( TYPE statement). You must use END TYPE with TYPE. n% Ends a program and returns the value n% to the operating system (if n% is omitted, the value of n% is set to 0). END is not required at the end of a program. In Syntax 2, n% accepts a range of integers from -32768 through 32767, inclusive. Statement Description ---------------------------------------------------------------------------- 32767, inclusive. The value n% can be used by DOS or OS-2 batch files or by non-BASIC programs. Untrapped errors and fatal errors set the value of n% to -1. By itself, the END statement stops program execution and closes all files. In a stand-alone program, END returns control to the operating system. In the QBX environment, END returns to that environment. You can place an END statement anywhere in the program to terminate execution. See Also DEF FN, FUNCTION, IF... THEN... ELSE, SELECT CASE, STOP, SUB, SYSTEM, TYPE Example See the on error statement programming example, which uses the END statement.